package com.neulogistics.contrib.warehouse.infrastructure.persistence.orm.po;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;
import lombok.Data;

/**
 * 库存信息表
 * @TableName tb_inventory
 */
@TableName(value ="tb_inventory", autoResultMap = true)
@Data
public class InventoryPO implements Serializable {
    /**
     * 库存id
     */
    @TableId(value = "inventory_id", type = IdType.AUTO)
    private Integer inventoryId;

    /**
     * 库房id
     */
    @TableField(value = "warehouse_id")
    private Integer warehouseId;

    /**
     * 商品id
     */
    @TableField(value = "goods_id")
    private Integer goodsId;

    /**
     * 商品名
     */
    @TableField(value = "goods_name", condition = SqlCondition.LIKE)
    private String goodsName;

    /**
     * 计量单位
     */
    @TableField(value = "measure_unit")
    private String measureUnit;

    /**
     * 最大值
     */
    @TableField(value = "max_hold")
    private Integer maxHold;

    /**
     * 预警值
     */
    @TableField(value = "warn_hold")
    private Integer warnHold;

    /**
     * 总库存量
     */
    @TableField(value = "total_hold")
    private Integer totalHold;

    /**
     * 可分配量
     */
    @TableField(value = "available_hold")
    private Integer availableHold;

    /**
     * 退回数量
     */
    @TableField(value = "return_hold")
    private Integer returnHold;

    /**
     * 已分配量
     */
    @TableField(value = "allocated_hold")
    private Integer allocatedHold;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 是否删除
     */
    @TableField(value = "deleted")
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public InventoryPO() {
    }

    public InventoryPO(Integer warehouseId, Integer goodsId, String goodsName, String measureUnit) {
        this.warehouseId = warehouseId;
        this.goodsId = goodsId;
        this.goodsName = goodsName;
        this.measureUnit = measureUnit;
        maxHold = 400;
        warnHold = 200;
        totalHold = 0;
        availableHold = 0;
        allocatedHold = 0;
        returnHold = 0;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        InventoryPO other = (InventoryPO) that;
        return (this.getInventoryId() == null ? other.getInventoryId() == null : this.getInventoryId().equals(other.getInventoryId()))
            && (this.getWarehouseId() == null ? other.getWarehouseId() == null : this.getWarehouseId().equals(other.getWarehouseId()))
            && (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
            && (this.getGoodsName() == null ? other.getGoodsName() == null : this.getGoodsName().equals(other.getGoodsName()))
            && (this.getMeasureUnit() == null ? other.getMeasureUnit() == null : this.getMeasureUnit().equals(other.getMeasureUnit()))
            && (this.getMaxHold() == null ? other.getMaxHold() == null : this.getMaxHold().equals(other.getMaxHold()))
            && (this.getWarnHold() == null ? other.getWarnHold() == null : this.getWarnHold().equals(other.getWarnHold()))
            && (this.getTotalHold() == null ? other.getTotalHold() == null : this.getTotalHold().equals(other.getTotalHold()))
            && (this.getAvailableHold() == null ? other.getAvailableHold() == null : this.getAvailableHold().equals(other.getAvailableHold()))
            && (this.getReturnHold() == null ? other.getReturnHold() == null : this.getReturnHold().equals(other.getReturnHold()))
            && (this.getAllocatedHold() == null ? other.getAllocatedHold() == null : this.getAllocatedHold().equals(other.getAllocatedHold()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((this.getInventoryId() == null) ? 0 : this.getInventoryId().hashCode());
        result = prime * result + ((getWarehouseId() == null) ? 0 : getWarehouseId().hashCode());
        result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
        result = prime * result + ((getGoodsName() == null) ? 0 : getGoodsName().hashCode());
        result = prime * result + ((getMeasureUnit() == null) ? 0 : getMeasureUnit().hashCode());
        result = prime * result + ((getMaxHold() == null) ? 0 : getMaxHold().hashCode());
        result = prime * result + ((getWarnHold() == null) ? 0 : getWarnHold().hashCode());
        result = prime * result + ((getTotalHold() == null) ? 0 : getTotalHold().hashCode());
        result = prime * result + ((getAvailableHold() == null) ? 0 : getAvailableHold().hashCode());
        result = prime * result + ((getReturnHold() == null) ? 0 : getReturnHold().hashCode());
        result = prime * result + ((getAllocatedHold() == null) ? 0 : getAllocatedHold().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", inventoryId=").append(inventoryId);
        sb.append(", warehouseId=").append(warehouseId);
        sb.append(", goodsId=").append(goodsId);
        sb.append(", goodsName=").append(goodsName);
        sb.append(", measureUnit=").append(measureUnit);
        sb.append(", maxHold=").append(maxHold);
        sb.append(", warnHold=").append(warnHold);
        sb.append(", totalHold=").append(totalHold);
        sb.append(", availableHold=").append(availableHold);
        sb.append(", returnHold=").append(returnHold);
        sb.append(", allocatedHold=").append(allocatedHold);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", deleted=").append(deleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}